package com.yunji.web.message;

import com.yunji.base.business.MalfunctionBusiness;
import com.yunji.base.domain.MalfunctionDO;
import com.yunji.common.base.response.Response;
import com.yunji.common.base.response.ResponseHelper;
import com.yunji.common.model.dto.MalfunctionDTO;
import com.yunji.common.model.params.MalfunctionParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @Project: yunji-coffee
 * @Package: com.yunji.web.message
 * @Title: MalfunctionController
 * <p>
 * History:
 * Date                     Version     Author          Summary
 * ============================================================
 * 2024-10-30 14:27:18      V1.0        HuaAo       新建类
 */
@RestController
@Api(tags = "管理端-故障类型")
@RequestMapping("/container/malfunction")
public class MalfunctionController {

    @Resource
    MalfunctionBusiness business;

    @ApiOperation("故障类型列表")
    @GetMapping("/list")
    public Response<List<MalfunctionDO>> list(MalfunctionParam param) {
        return ResponseHelper.successWithPage(business.list(param));
    }

    @ApiOperation("新增故障类型")
    @PostMapping("/create")
    public Response<?> create(@Valid @RequestBody MalfunctionDTO dto) {
        return ResponseHelper.success(business.create(dto), "创建失败");
    }

    @ApiOperation("编辑故障类型")
    @PutMapping("/edit")
    public Response<?> edit(@Valid @RequestBody MalfunctionDTO malfunction) {
        return ResponseHelper.handle(business.edit(malfunction), "修改失败");
    }

    @ApiOperation("删除故障类型")
    @DeleteMapping("/{ids}")
    public Response<?> delete(@PathVariable List<Long> ids) {
        return ResponseHelper.handle(business.delete(ids), "删除失败");
    }

}